package com.person.android.widgets;

import android.app.Dialog;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.person.android.formatts.R;

/**
 * @autor zhaokang.
 * @time on 2015/12/11.
 */
public class TransformProgressDialog extends Dialog {

    private static RoundProgressBar mProgressBar;

    public TransformProgressDialog(Context context) {
        super(context);
        setCanceledOnTouchOutside(false);
    }

    public TransformProgressDialog(Context context, int themeResId) {
        super(context, themeResId);
        setCanceledOnTouchOutside(false);
    }

    public static final class Builder {
        private String title;
        private Context context;
        private View contentView;

        public Builder(Context context) {
            this.context = context;
        }

        public Builder setTitle(int titleID) {
            this.title = context.getString(titleID);
            return this;
        }

        public TransformProgressDialog create() {
            LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            final TransformProgressDialog dialog = new TransformProgressDialog(context,R.style.progress_dialog);
            View layout = inflater.inflate(R.layout.transform_progress_dialog_layout, null);
            dialog.addContentView(layout, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
            if (title != null){
                ((TextView)layout.findViewById(R.id.title)).setText(title);
            }
            mProgressBar = (RoundProgressBar) layout.findViewById(R.id.roundProgressBar);
            dialog.setContentView(layout);
            return dialog;
        }


    }

    public RoundProgressBar getRoundProgressBar() {
        return mProgressBar;
    }
}